home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_400 / 414_02 / portable / ungetch.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-06-17  |  1.2 KB  |  51 lines

  1. #define    CURSES_LIBRARY    1
  2. #include <curses.h>
  3. #undef    ungetch
  4.  
  5. #ifdef PDCDEBUG
  6. char *rcsid_ungetch = "$Header: C:\CURSES\portable\RCS\ungetch.c 2.1 1993/06/18 20:21:24 MH Rel MH $";
  7. #endif
  8.  
  9.  
  10.  
  11.  
  12. /*man-start*********************************************************************
  13.  
  14.   ungetch()    - pushes a character back onto the input stream
  15.  
  16.   PDCurses Description:
  17.      There is only one input stream to ungetch characters onto.  It
  18.      is of size NUNGETCH.
  19.  
  20.   PDCurses Return Value:
  21.      The ungetch() routine returns OK upon success otherwise ERR is
  22.      returned.
  23.  
  24.   PDCurses Errors:
  25.      ERR will be returned when the push back stack is full.
  26.  
  27.   Portability:
  28.      PDCurses    ungetch( chtype ch );
  29.      SysV Curses    
  30.      BSD Curses    
  31.  
  32. **man-end**********************************************************************/
  33.  
  34. int    ungetch(chtype ch)
  35. {
  36. extern    int    c_pindex;        /* putter index */
  37. extern    int    c_gindex;        /* getter index */
  38. extern    int    c_ungind;        /* wungetch() push index */
  39. extern    chtype    c_ungch[NUNGETCH];    /* array of ungotten chars */
  40.  
  41. #ifdef PDCDEBUG
  42.     if (trace_on) PDC_debug("ungetch() - called\n");
  43. #endif
  44.  
  45.     if (c_ungind >= NUNGETCH)    /* pushback stack full */
  46.         return( ERR );
  47.  
  48.     c_ungch[c_ungind++] = ch;
  49.     return( OK );
  50. }
  51.